package edu.sctu.renpingan.imitatesubwaysystem;

import java.util.HashMap;
import java.util.List;

/**
 * Created by user18 on 2015/5/31.
 */
public class Passager {
    /**
     * 姓名
     * 携带物
     * 地铁卡
     */
    public SubwayCard subwayCard;
    public String start;
    public String end;
    public String name;
    CarryThing carry = new CarryThing();
    SubwayCard card = new SubwayCard();
    Station station = new Station();
    PassagerData passagerData = new PassagerData();

    HashMap<String, List<String>> map = passagerData.setPassager();

    //判断卡
    public void HaveCard(String name,String start , String end) {
        this.start = start;
        this.end = end;
        this.name = name;
        if(carry.haveCard(map.get(name))){
            if(carry.judgeDangerous(map.get(name))){
                System.out.println("您好"+name+"   您携带危险物品，不能进入");
            }else{
                System.out.println("您好"+name+"   谢谢配合，祝您旅途愉快");
                if (passagerData.balance.get(name)>=2){
                    System.out.println("您好"+name+"   您现在余额有"+passagerData.balance.get(name));
                }else{
                    System.out.println("您好"+name+"   您的余额已不足");
                    int recharge = card.recharge(passagerData.balance.get(name), 20);
                    System.out.println("您好"+name+"    您充值后的余额为："+recharge);
                }
            }
        }else{
            carry.buySingTickets(start,end);
            if(carry.judgeDangerous(map.get(name))){
                System.out.println("您好"+name+"   您携带危险物品，不能进入");
            }else {
                System.out.println("您好"+name+"   谢谢配合，祝您旅途愉快");
            }
        }
    }


    public int consume(){
        int consume = station.getconsume(start,end);
        int charge = card.getBalance(passagerData.balance.get(name),consume);
        System.out.println(charge);
        return charge;
    }







}
